<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/include/taglibs.jsp"%>
<script type="text/javascript">

$(document).ready(function(){

});

//데이터 저장
function submitData(){
	if(confirm("저장하시겠습니까?")){
		$("#frmData").submit();	
	}
	
}

//데이터 삭제  
function deleteData(no){
	if(confirm("삭제하시겠습니까?")){
		location.href="./peti601T.do?p_id=${map.p_id}&sc_no="+no;	
	}
	
}

//기본요금 변경
function setBasePay(sms_pay){
	if(confirm("요금을 변경하시겠습니까?")){
		location.href="./peti602T.do?p_id=${map.p_id}&sms_pay="+$("#sms_pay").val();	
	}
	
	
}

//요금 설정 구매
function setMoney(type,val){
	if(type==1){
		$('#sc_pay').val($(val).val()*$('#sms_pay').val());
	}else{
		$('#sc_cnt').val($.frp($(val).val()/$("#sms_pay").val(),0));
	}
}
</script>

<%@ include file="/WEB-INF/jsp/pmgr/pe/ti/page_top.jsp"%>


<table width="700" >
<tr>
	<td align="left">충전하기</td>
	<td align="right">&nbsp;
		기본가격 <input name="sms_pay" id="sms_pay" value="${map.sms_pay }" type="text"/><input type="button" onclick="setBasePay();" value=" 저 장 ">
	</td>
</tr>
</table>
	<form action="./peti600T.do" id="frmData" method="post" name="form1">
		<input type="hidden" name="p_id" value="${param.p_id }">
		<table width="700" border="0"  cellspacing="1" cellpadding="2" class="class_admin_table">
		<tr> 
			<td height="25" class="class_admin_table_head" width="80" align="center">건수</td>
			<td height="25" class="class_admin_table_blank"> <input type="text" name="sc_cnt" id="sc_cnt" maxlength="10" size="10" value="" onkeyup="setMoney(1,this);"></td>
			<td height="25" class="class_admin_table_head" width="80" align="center">가격</td>
			<td height="25" class="class_admin_table_blank"><input type="text" name="sc_pay" id="sc_pay" maxlength="10" size="10" value="" onkeyup="setMoney(2,this);"></td>
			<td height="25" class="class_admin_table_head" width="80" align="center">메모</td>
			<td height="25" class="class_admin_table_blank"><input type="text" name="sc_memo" maxlength="40" size="40" value=""></td>
			<td height="25" class="class_admin_table_blank">
			<input type="button" onclick="submitData();" value=" 추 가 ">
			</td>
		</tr>
		
		</table>
	</form>

<br>
<table width="700" >
<tr>
	<td align="left">충전내역</td>
	<td align="right">현재잔여건수 : <b>${map.sms_cnt }건</b></td>
</tr>
</table>
<table width="700" border="0"  cellspacing="1" cellpadding="2" class="class_admin_table">
<tr height="25" class="class_admin_table_head">
	<td align="center" width="150">건수</td>
	<td align="center" width="150">가격</td>
	<td align="center">메모</td>
	<td align="center" width="150">등록일</td>
	<td align="center">삭제</td>
</tr>
<c:if test="${list !=null && fn:length(list)>0 }">
	<c:forEach var="map1" items="${list}" varStatus="status">
<tr height="25" class="class_admin_table_blank">
	<td align="center">${map1.sc_cnt }</td>
	<td align="center">${map1.sc_pay }</td>
	<td>${map1.sc_memo }</td>
	<td align="center">${map1.reg_dt_n }</td>
	<td align="center">
		<a href="#" onclick="deleteData('${map1.sc_no}');">삭제</a>
	</td>
</tr>
	</c:forEach>
</c:if>

</table>


<table width="700" border="0"  cellspacing="1" cellpadding="2" class="class_admin_table_nocolor">
<tr> 
	<td height="25"  align="center">
	<input type="button" onclick="location.href='?menu=pension&mode=list&page=1'" value=" 펜 션 목 록 "> 
	</td>
</tr>
</table>	
